#include <stdio.h>
#include <math.h>
int main()
{
    int i = 0;
    for (i = 1; i <= 100000; i++)
    {
        int n = 1;
        int tmp = i;
        while (tmp / 10)
        {
            n++;
            tmp /= 10;
        }
        tmp = i;
        int sum = 0;
        while (tmp)
        {
            sum += (int)pow(tmp % 10, n);
            tmp /= 10;
        }
        if (sum == i)
            printf("%d ", i);
    }
    return 0;
}